Xbasic

NamedFormatExpression Example

Description

The SQL::DataTypeInfo.NamedFormatExpression property is a CR-LF delimited list of expressions in the following format:

Xbasic_Expression

or

Name1 = Xbasic_Expression_1
[ CR-LF Name2 = Xbasic_Expression_2 ]
...
[ CR-LF NameN = Xbasic_Expression_N ]

The Xbasic_Expression is used to format the data when the named format is requested. The expression executes in a context that has the following predefined variables:

  • CurrentRow as SQL::Row

  • ColumnDefinition as SQL::DataTypeInfo

  • Context as P

  • ColumnIndex as N

  • ColumnValue as A

This creates a single default format.

alltrim(CurrentRow.Data("Description"))

This creates a list of two named formats.

Short=Left(CurrentRow.Data("Description"))
Long=CurrentRow.Data("A")

Example

dim c as sql::connection
? c.open("{A5API=Access,FileName='C:\Databases\Northwind\NorthWIND.MDB', UserName='Admin'}")
= .T.
? c.execute("select * from customers")
= .T.
c.resultset.columninfo[1].namedformatexpressions = "\"Row: \" + CurrentRow.RowIndex + \" Column: \" + ColumnIndex + \" = \" + ColumnValue"
? c.resultset.columninfo[1].namedformatexpressions
= "Row: " + CurrentRow.RowIndex + " Column: " + ColumnIndex + " = " + ColumnValue
? c.resultset.tostring(5)
= Row: 1 Column: 1 = ALFKI Alfreds Futterkiste Maria Anders Sales Representative Obere Str. 57 Berlin 12209 Germany 030-0074321 030-0076545
Row: 2 Column: 1 = ANATR Ana Trujillo Emparedados y helados Ana Trujillo Owner Avda. de la Constitucion 2222 Mexico D.F. 05021 Mexico (5) 555-4729 (5) 555-3745
Row: 3 Column: 1 = ANTON Antonio Moreno Taqueria Antonio Moreno Owner Mataderos 2312 Mexico D.F. 05023 Mexico (5) 555-3932
Row: 4 Column: 1 = AROUT Around the Horn Thomas Hardy Sales Representative 120 Hanover Sq. London WA1 1DP UK (171) 555-7788 (171) 555-6750
Row: 5 Column: 1 = BERGS Berglunds snabbkop Christina Berglund Order Administrator Berguvsvogen 8 Luleo S-958 22 Sweden 0921-12 34 65 0921-12 34 67

See Also